
#ifndef STUDENT_HXX
#define STUDENT_HXX



#include<iostream>
#include <odb/core.hxx>
#include<odb/nullable.hxx>

#pragma db object
class Student{
    public:
    Student(){}
    Student(const std::string &name,const unsigned long&sn,const unsigned short&age,const unsigned long&cid)
    :_name(name),_sn(sn),_age(age),_classes_id(cid){
    }
    void name(const std::string name){
        _name=name;
    }
    std::string name(){
        return _name;
    }
    void sn(const unsigned long sn){
        _sn=sn;
    }
    unsigned long sn(){
        return _sn;
    }

    void age(const unsigned short age){
        _age=age;
    }
    odb::nullable<unsigned short> age(){
        return _age;
    }

    void classes_id(const unsigned long id){
        _classes_id=id;
    }
    unsigned long classes_id(){
        return _classes_id;
    }
    private:
    friend class odb::access;
    #pragma db id auto
    unsigned long  _id;
    std::string _name;
    #pragma db unique
    unsigned long _sn;
    odb::nullable<unsigned short> _age;
    #pragma db index
    unsigned long _classes_id;
};

#pragma db object
class Classes{
    public:
    Classes(){}
    Classes(const std::string name):_name(name){
    }
    void name(const std::string name){
        _name=name;
    }
    std::string name(){
        return _name;
    }
    private:
    friend class odb::access;
    std::string _name;
    #pragma db id auto
    unsigned long _id;
};

#pragma db view object(Student)\
                object(Classes=classes:Student::_classes_id==classes::_id)\
                query((?))
struct classes_student{
    #pragma db column(Student::_id)
    unsigned long id;
    #pragma db column(Student::_name)
    std::string name;
    #pragma db column(Student::_sn)
    unsigned long sn;
    #pragma db column(Student::_age)
     odb::nullable<unsigned short> _age;
    #pragma db column(classes::_name)
    std::string classes_name;

};
#pragma db view query("select name from Student")
struct all_name{
    std::string name;
};
//odb -d mysql  --std c++11  --generate-query  --generate-schema --profile boost/date-time person.hxx
#endif 